home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / mail / sendmail / UCB / sendmail.8.6.10.patch.Z / sendmail.8.6.10.patch
Encoding:
Text File  |  1995-02-21  |  24.5 KB  |  1,047 lines

  1. *** RELEASE_NOTES.OLD    Sat Feb 11 08:50:50 1995
  2. --- RELEASE_NOTES    Fri Feb 10 09:55:32 1995
  3. ***************
  4. *** 1,10 ****
  5.               SENDMAIL RELEASE NOTES
  6. !          @(#)RELEASE_NOTES    8.6.9.2 (Berkeley) 4/19/94
  7.   
  8.   This listing shows the version of the sendmail binary, the version
  9.   of the sendmail configuration files, the date of release, and a
  10.   summary of the changes in that release.
  11.   
  12.   8.6.9/8.6.9    94/04/19
  13.       Do all mail delivery completely disconnected from any terminal.
  14.           This provides consistency with daemon delivery and
  15. --- 1,52 ----
  16.               SENDMAIL RELEASE NOTES
  17. !          @(#)RELEASE_NOTES    8.6.10.2 (Berkeley) 2/10/95
  18.   
  19.   This listing shows the version of the sendmail binary, the version
  20.   of the sendmail configuration files, the date of release, and a
  21.   summary of the changes in that release.
  22.   
  23. + 8.6.10/8.6.10    95/02/10
  24. +     SECURITY: Diagnose bogus values to some command line flags that
  25. +         could allow trash to get into headers and qf files.
  26. +     Validate the name of the user returned by the IDENT protocol.
  27. +         Some systems that really dislike IDENT send intentionally
  28. +         bogus information.  Problem pointed out by Michael Bushnell
  29. +         of the Free Software Foundation.  Has some security
  30. +         implications.
  31. +     Fix a problem causing error messages about DNS problems when
  32. +         the host name contained a percent sign to act oddly
  33. +         because it was passed as a printf-style format string.
  34. +         In some cases this could cause core dumps.
  35. +     Avoid possible buffer overrun in returntosender() if error
  36. +         message is quite ling.  From Fletcher Mattox of the
  37. +         University of Texas.
  38. +     Fix a problem that would silently drop "too many hops" error
  39. +         messages if and only if you were sending to an alias.
  40. +         From Jon Giltner of the University of Colorado and
  41. +         Dan Harton of Oak Ridge National Laboratory.
  42. +     Fix a bug that caused core dumps on some systems if -d11.2 was
  43. +         set and e->e_message was null.  Fix from Bruce Nagel of
  44. +         Data General.
  45. +     Fix problem that can still cause df files to be left around
  46. +         after "hop count exceeded" messages.  Fix from Andrew
  47. +         Chang and Shau-Ping Lo of SunSoft.
  48. +     Fix a problem that can cause buffer overflows on very long
  49. +         user names (as might occur if you piped to a program
  50. +         with a lot of arguments).
  51. +     Avoid returning an error and re-queueing if the host signature
  52. +         is null; this can occur on addresses like ``user@.''.
  53. +         Problem noted by Wesley Craig and the University of
  54. +         Michigan.
  55. +     Avoid possible calls to malloc(0) if MCI caching is turned
  56. +         off.  Bug fix from Pierre David of the Laboratoire
  57. +         Parallelisme, Reseaux, Systemes et Modelisation (PRiSM),
  58. +         Universite de Versailles - St Quentin, and Jacky
  59. +         Thibault.
  60. +     Make a local copy of the line being sent via senttolist() -- in
  61. +         some cases, buffers could get trashed by map lookups
  62. +         causing it to do unexpected things.  This also simplifies
  63. +         some of the map code.
  64.   8.6.9/8.6.9    94/04/19
  65.       Do all mail delivery completely disconnected from any terminal.
  66.           This provides consistency with daemon delivery and
  67. ***************
  68. *** 25,31 ****
  69.           sendmail -bs from inetd.  Based on code contributed by
  70.           Todd Miller (this problem was also reported by Guy Helmer
  71.           of Dakota State University).  This also fixes a related
  72. !         problem reported by Liudvikas Bukys of Rochester University.
  73.       Parameterize "nroff -h" in all the Makefiles so people with
  74.           variant versions can use them easily.  Suggested by
  75.           Peter Collinson of Hillside Systems.
  76. --- 67,74 ----
  77.           sendmail -bs from inetd.  Based on code contributed by
  78.           Todd Miller (this problem was also reported by Guy Helmer
  79.           of Dakota State University).  This also fixes a related
  80. !         problem reported by Liudvikas Bukys of the University of
  81. !         Rochester.
  82.       Parameterize "nroff -h" in all the Makefiles so people with
  83.           variant versions can use them easily.  Suggested by
  84.           Peter Collinson of Hillside Systems.
  85. ***************
  86. *** 418,424 ****
  87.           when sending error messages.  This resulted in
  88.           "unexpected close" messages.  It should fix itself
  89.           on the following queue run.  Problem noted by
  90. !         Liudvikas Bukys of Rochester University.
  91.       Include $k in $=k as documented in the Install & Op Guide.
  92.           This seems odd, but it was documented....  From
  93.           Michael Corrigan of UCSD.
  94. --- 461,467 ----
  95.           when sending error messages.  This resulted in
  96.           "unexpected close" messages.  It should fix itself
  97.           on the following queue run.  Problem noted by
  98. !         Liudvikas Bukys of the University of Rochester.
  99.       Include $k in $=k as documented in the Install & Op Guide.
  100.           This seems odd, but it was documented....  From
  101.           Michael Corrigan of UCSD.
  102. *** cf/m4/version.m4.OLD    Fri Feb 10 08:20:27 1995
  103. --- cf/m4/version.m4    Fri Feb 10 08:14:41 1995
  104. ***************
  105. *** 32,39 ****
  106.   # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  107.   # SUCH DAMAGE.
  108.   #
  109. ! VERSIONID(`@(#)version.m4    8.6.9.1 (Berkeley) 4/18/94')
  110.   #
  111.   divert(0)
  112.   # Configuration version number
  113. ! DZ8.6.9
  114. --- 32,39 ----
  115.   # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  116.   # SUCH DAMAGE.
  117.   #
  118. ! VERSIONID(`@(#)version.m4    8.6.10.1 (Berkeley) 2/10/95')
  119.   #
  120.   divert(0)
  121.   # Configuration version number
  122. ! DZ8.6.10
  123. *** src/daemon.c.OLD    Thu Feb  9 12:37:25 1995
  124. --- src/daemon.c    Thu Feb  9 17:28:51 1995
  125. ***************
  126. *** 37,45 ****
  127.   
  128.   #ifndef lint
  129.   #ifdef DAEMON
  130. ! static char sccsid[] = "@(#)daemon.c    8.48 (Berkeley) 4/18/94 (with daemon mode)";
  131.   #else
  132. ! static char sccsid[] = "@(#)daemon.c    8.48 (Berkeley) 4/18/94 (without daemon mode)";
  133.   #endif
  134.   #endif /* not lint */
  135.   
  136. --- 37,45 ----
  137.   
  138.   #ifndef lint
  139.   #ifdef DAEMON
  140. ! static char sccsid[] = "@(#)daemon.c    8.48.1.2 (Berkeley) 2/9/95 (with daemon mode)";
  141.   #else
  142. ! static char sccsid[] = "@(#)daemon.c    8.48.1.2 (Berkeley) 2/9/95 (without daemon mode)";
  143.   #endif
  144.   #endif /* not lint */
  145.   
  146. ***************
  147. *** 1122,1130 ****
  148.       while (isascii(*++p) && isspace(*p))
  149.           continue;
  150.   
  151. !     /* p now points to the authenticated name */
  152. !     (void) sprintf(hbuf, "%s@%s",
  153. !         p, RealHostName == NULL ? "localhost" : RealHostName);
  154.       goto finish;
  155.   
  156.   closeident:
  157. --- 1122,1132 ----
  158.       while (isascii(*++p) && isspace(*p))
  159.           continue;
  160.   
  161. !     /* p now points to the authenticated name -- copy carefully */
  162. !     cleanstrcpy(hbuf, p, MAXNAME);
  163. !     i = strlen(hbuf);
  164. !     hbuf[i++] = '@';
  165. !     strcpy(&hbuf[i], RealHostName == NULL ? "localhost" : RealHostName);
  166.       goto finish;
  167.   
  168.   closeident:
  169. *** src/deliver.c.OLD    Thu Feb  9 12:37:29 1995
  170. --- src/deliver.c    Fri Feb 10 07:38:10 1995
  171. ***************
  172. *** 33,39 ****
  173.    */
  174.   
  175.   #ifndef lint
  176. ! static char sccsid[] = "@(#)deliver.c    8.82 (Berkeley) 4/18/94";
  177.   #endif /* not lint */
  178.   
  179.   #include "sendmail.h"
  180. --- 33,39 ----
  181.    */
  182.   
  183.   #ifndef lint
  184. ! static char sccsid[] = "@(#)deliver.c    8.84.1.1 (Berkeley) 2/10/95";
  185.   #endif /* not lint */
  186.   
  187.   #include "sendmail.h"
  188. ***************
  189. *** 124,129 ****
  190. --- 124,130 ----
  191.       if (e->e_hopcount > MaxHopCount)
  192.       {
  193.           errno = 0;
  194. +         queueup(e, TRUE, announcequeueup);
  195.           e->e_flags |= EF_FATALERRS|EF_PM_NOTIFY|EF_CLRQUEUE;
  196.           syserr("554 too many hops %d (%d max): from %s via %s, to %s",
  197.               e->e_hopcount, MaxHopCount, e->e_from.q_paddr,
  198. ***************
  199. *** 1005,1011 ****
  200.           if (curhost == NULL || curhost[0] == '\0')
  201.           {
  202.               syserr("null host signature for %s", pv[1]);
  203. !             rcode = EX_OSERR;
  204.               goto give_up;
  205.           }
  206.   
  207. --- 1006,1012 ----
  208.           if (curhost == NULL || curhost[0] == '\0')
  209.           {
  210.               syserr("null host signature for %s", pv[1]);
  211. !             rcode = EX_CONFIG;
  212.               goto give_up;
  213.           }
  214.   
  215. ***************
  216. *** 1726,1732 ****
  217.       else if (stat == EX_NOHOST && h_errno != 0)
  218.       {
  219.           statmsg = errstring(h_errno + E_DNSBASE);
  220. !         (void) sprintf(buf, "%s (%s)", SysExMsg[i], statmsg);
  221.           statmsg = buf;
  222.       }
  223.   #endif
  224. --- 1727,1733 ----
  225.       else if (stat == EX_NOHOST && h_errno != 0)
  226.       {
  227.           statmsg = errstring(h_errno + E_DNSBASE);
  228. !         (void) sprintf(buf, "%s (%s)", SysExMsg[i] + 1, statmsg);
  229.           statmsg = buf;
  230.       }
  231.   #endif
  232. ***************
  233. *** 1754,1761 ****
  234.       }
  235.       else
  236.       {
  237.           Errors++;
  238. !         usrerr(statmsg, errstring(errno));
  239.       }
  240.   
  241.       /*
  242. --- 1755,1765 ----
  243.       }
  244.       else
  245.       {
  246. +         char mbuf[8];
  247.           Errors++;
  248. !         sprintf(mbuf, "%.3s %%s", statmsg);
  249. !         usrerr(mbuf, &statmsg[4]);
  250.       }
  251.   
  252.       /*
  253. ***************
  254. *** 1770,1776 ****
  255.   
  256.       if (tTd(11, 2))
  257.           printf("giveresponse: stat=%d, e->e_message=%s\n",
  258. !             stat, e->e_message);
  259.   
  260.       if (stat != EX_TEMPFAIL)
  261.           setstat(stat);
  262. --- 1774,1780 ----
  263.   
  264.       if (tTd(11, 2))
  265.           printf("giveresponse: stat=%d, e->e_message=%s\n",
  266. !             stat, e->e_message == NULL ? "<NULL>" : e->e_message);
  267.   
  268.       if (stat != EX_TEMPFAIL)
  269.           setstat(stat);
  270. *** src/main.c.OLD    Thu Feb  9 12:21:45 1995
  271. --- src/main.c    Fri Feb 10 09:40:49 1995
  272. ***************
  273. *** 39,45 ****
  274.   #endif /* not lint */
  275.   
  276.   #ifndef lint
  277. ! static char sccsid[] = "@(#)main.c    8.55 (Berkeley) 4/15/94";
  278.   #endif /* not lint */
  279.   
  280.   #define    _DEFINE
  281. --- 39,45 ----
  282.   #endif /* not lint */
  283.   
  284.   #ifndef lint
  285. ! static char sccsid[] = "@(#)main.c    8.55.1.3 (Berkeley) 2/10/95";
  286.   #endif /* not lint */
  287.   
  288.   #define    _DEFINE
  289. ***************
  290. *** 463,469 ****
  291.               break;
  292.   
  293.             case 'B':    /* body type */
  294. !             CurEnv->e_bodytype = newstr(optarg);
  295.               break;
  296.   
  297.             case 'C':    /* select configuration file (already done) */
  298. --- 463,473 ----
  299.               break;
  300.   
  301.             case 'B':    /* body type */
  302. !             if (strcasecmp(optarg, "7bit") == 0 ||
  303. !                 strcasecmp(optarg, "8bitmime") == 0)
  304. !                 CurEnv->e_bodytype = newstr(optarg);
  305. !             else
  306. !                 usrerr("Illegal body type %s", optarg);
  307.               break;
  308.   
  309.             case 'C':    /* select configuration file (already done) */
  310. ***************
  311. *** 486,492 ****
  312.                   ExitStat = EX_USAGE;
  313.                   break;
  314.               }
  315. !             from = newstr(optarg);
  316.               if (strcmp(RealUserName, from) != 0)
  317.                   warn_f_flag = j;
  318.               break;
  319. --- 490,496 ----
  320.                   ExitStat = EX_USAGE;
  321.                   break;
  322.               }
  323. !             from = newstr(denlstring(optarg));
  324.               if (strcmp(RealUserName, from) != 0)
  325.                   warn_f_flag = j;
  326.               break;
  327. ***************
  328. *** 516,526 ****
  329.             case 'p':    /* set protocol */
  330.               p = strchr(optarg, ':');
  331.               if (p != NULL)
  332.                   *p++ = '\0';
  333.               if (*optarg != '\0')
  334. !                 define('r', newstr(optarg), CurEnv);
  335. !             if (p != NULL && *p != '\0')
  336. !                 define('s', newstr(p), CurEnv);
  337.               break;
  338.   
  339.             case 'q':    /* run queue files at intervals */
  340. --- 520,540 ----
  341.             case 'p':    /* set protocol */
  342.               p = strchr(optarg, ':');
  343.               if (p != NULL)
  344. +             {
  345.                   *p++ = '\0';
  346. +                 if (*p != '\0')
  347. +                 {
  348. +                     ep = xalloc(strlen(p) + 1);
  349. +                     cleanstrcpy(ep, p, MAXNAME);
  350. +                     define('s', ep, CurEnv);
  351. +                 }
  352. +             }
  353.               if (*optarg != '\0')
  354. !             {
  355. !                 ep = xalloc(strlen(optarg) + 1);
  356. !                 cleanstrcpy(ep, optarg, MAXNAME);
  357. !                 define('r', ep, CurEnv);
  358. !             }
  359.               break;
  360.   
  361.             case 'q':    /* run queue files at intervals */
  362. ***************
  363. *** 713,718 ****
  364. --- 727,736 ----
  365.           FullName = NULL;
  366.           break;
  367.       }
  368. +     /* full names can't have newlines */
  369. +     if (FullName != NULL && strchr(FullName, '\n') != NULL)
  370. +         FullName = newstr(denlstring(FullName));
  371.   
  372.       /* do heuristic mode adjustment */
  373.       if (Verbose)
  374. *** src/map.c.OLD    Fri Feb 10 07:51:55 1995
  375. --- src/map.c    Fri Feb 10 07:51:42 1995
  376. ***************
  377. *** 33,39 ****
  378.    */
  379.   
  380.   #ifndef lint
  381. ! static char sccsid[] = "@(#)map.c    8.25 (Berkeley) 4/17/94";
  382.   #endif /* not lint */
  383.   
  384.   #include "sendmail.h"
  385. --- 33,39 ----
  386.    */
  387.   
  388.   #ifndef lint
  389. ! static char sccsid[] = "@(#)map.c    8.25.1.1 (Berkeley) 2/10/95";
  390.   #endif /* not lint */
  391.   
  392.   #include "sendmail.h"
  393. ***************
  394. *** 189,208 ****
  395.   **        av -- arguments to interpolate into buf.
  396.   **
  397.   **    Returns:
  398. ! **        Pointer to rewritten result.
  399.   **
  400.   **    Side Effects:
  401.   **        none.
  402.   */
  403.   
  404. - struct rwbuf
  405. - {
  406. -     int    rwb_len;    /* size of buffer */
  407. -     char    *rwb_buf;    /* ptr to buffer */
  408. - };
  409. - struct rwbuf    RwBufs[2];    /* buffers for rewriting output */
  410.   char *
  411.   map_rewrite(map, s, slen, av)
  412.       register MAP *map;
  413. --- 189,201 ----
  414.   **        av -- arguments to interpolate into buf.
  415.   **
  416.   **    Returns:
  417. ! **        Pointer to rewritten result.  This is static data that
  418. ! **        should be copied if it is to be saved!
  419.   **
  420.   **    Side Effects:
  421.   **        none.
  422.   */
  423.   
  424.   char *
  425.   map_rewrite(map, s, slen, av)
  426.       register MAP *map;
  427. ***************
  428. *** 214,222 ****
  429.       register char c;
  430.       char **avp;
  431.       register char *ap;
  432. -     register struct rwbuf *rwb;
  433.       int i;
  434.       int len;
  435.   
  436.       if (tTd(39, 1))
  437.       {
  438. --- 207,216 ----
  439.       register char c;
  440.       char **avp;
  441.       register char *ap;
  442.       int i;
  443.       int len;
  444. +     static int buflen = -1;
  445. +     static char *buf = NULL;
  446.   
  447.       if (tTd(39, 1))
  448.       {
  449. ***************
  450. *** 231,240 ****
  451.           printf("\n");
  452.       }
  453.   
  454. -     rwb = RwBufs;
  455. -     if (av == NULL)
  456. -         rwb++;
  457.       /* count expected size of output (can safely overestimate) */
  458.       i = len = slen;
  459.       if (av != NULL)
  460. --- 225,230 ----
  461. ***************
  462. *** 258,273 ****
  463.       }
  464.       if (map->map_app != NULL)
  465.           len += strlen(map->map_app);
  466. !     if (rwb->rwb_len < ++len)
  467.       {
  468.           /* need to malloc additional space */
  469. !         rwb->rwb_len = len;
  470. !         if (rwb->rwb_buf != NULL)
  471. !             free(rwb->rwb_buf);
  472. !         rwb->rwb_buf = xalloc(rwb->rwb_len);
  473.       }
  474.   
  475. !     bp = rwb->rwb_buf;
  476.       if (av == NULL)
  477.       {
  478.           bcopy(s, bp, slen);
  479. --- 248,263 ----
  480.       }
  481.       if (map->map_app != NULL)
  482.           len += strlen(map->map_app);
  483. !     if (buflen < ++len)
  484.       {
  485.           /* need to malloc additional space */
  486. !         buflen = len;
  487. !         if (buf != NULL)
  488. !             free(buf);
  489. !         buf = xalloc(buflen);
  490.       }
  491.   
  492. !     bp = buf;
  493.       if (av == NULL)
  494.       {
  495.           bcopy(s, bp, slen);
  496. ***************
  497. *** 307,314 ****
  498.       else
  499.           *bp = '\0';
  500.       if (tTd(39, 1))
  501. !         printf("map_rewrite => %s\n", rwb->rwb_buf);
  502. !     return rwb->rwb_buf;
  503.   }
  504.    /*
  505.   **  INITMAPS -- initialize for aliasing
  506. --- 297,304 ----
  507.       else
  508.           *bp = '\0';
  509.       if (tTd(39, 1))
  510. !         printf("map_rewrite => %s\n", buf);
  511. !     return buf;
  512.   }
  513.    /*
  514.   **  INITMAPS -- initialize for aliasing
  515. *** src/mci.c.OLD    Thu Feb  9 12:22:01 1995
  516. --- src/mci.c    Thu Feb  9 12:50:26 1995
  517. ***************
  518. *** 33,39 ****
  519.    */
  520.   
  521.   #ifndef lint
  522. ! static char sccsid[] = "@(#)mci.c    8.13 (Berkeley) 4/12/94";
  523.   #endif /* not lint */
  524.   
  525.   #include "sendmail.h"
  526. --- 33,39 ----
  527.    */
  528.   
  529.   #ifndef lint
  530. ! static char sccsid[] = "@(#)mci.c    8.14 (Berkeley) 5/15/94";
  531.   #endif /* not lint */
  532.   
  533.   #include "sendmail.h"
  534. ***************
  535. *** 83,94 ****
  536.       register MCI **mcislot;
  537.       extern MCI **mci_scan();
  538.   
  539. -     if (MaxMciCache <= 0)
  540. -     {
  541. -         /* we don't support caching */
  542. -         return;
  543. -     }
  544.       /*
  545.       **  Find the best slot.  This may cause expired connections
  546.       **  to be closed.
  547. --- 83,88 ----
  548. ***************
  549. *** 95,100 ****
  550. --- 89,99 ----
  551.       */
  552.   
  553.       mcislot = mci_scan(mci);
  554. +     if (mcislot == NULL)
  555. +     {
  556. +         /* we don't support caching */
  557. +         return;
  558. +     }
  559.   
  560.       /* if this is already cached, we are done */
  561.       if (bitset(MCIF_CACHED, mci->mci_flags))
  562. ***************
  563. *** 136,141 ****
  564. --- 135,146 ----
  565.       register MCI *mci;
  566.       register int i;
  567.   
  568. +     if (MaxMciCache <= 0)
  569. +     {
  570. +         /* we don't support caching */
  571. +         return NULL;
  572. +     }
  573.       if (MciCache == NULL)
  574.       {
  575.           /* first call */
  576. ***************
  577. *** 267,272 ****
  578. --- 272,278 ----
  579.   {
  580.       register MCI *mci;
  581.       register STAB *s;
  582. +     extern MCI **mci_scan();
  583.   
  584.   #ifdef DAEMON
  585.       extern SOCKADDR CurHostAddr;
  586. ***************
  587. *** 276,282 ****
  588.   #endif
  589.   
  590.       /* clear out any expired connections */
  591. !     mci_scan(NULL);
  592.   
  593.       if (m->m_mno < 0)
  594.           syserr("negative mno %d (%s)", m->m_mno, m->m_name);
  595. --- 282,288 ----
  596.   #endif
  597.   
  598.       /* clear out any expired connections */
  599. !     (void) mci_scan(NULL);
  600.   
  601.       if (m->m_mno < 0)
  602.           syserr("negative mno %d (%s)", m->m_mno, m->m_name);
  603. *** src/queue.c.OLD    Thu Feb  9 12:21:58 1995
  604. --- src/queue.c    Fri Feb 10 07:38:11 1995
  605. ***************
  606. *** 36,44 ****
  607.   
  608.   #ifndef lint
  609.   #ifdef QUEUE
  610. ! static char sccsid[] = "@(#)queue.c    8.41 (Berkeley) 4/18/94 (with queueing)";
  611.   #else
  612. ! static char sccsid[] = "@(#)queue.c    8.41 (Berkeley) 4/18/94 (without queueing)";
  613.   #endif
  614.   #endif /* not lint */
  615.   
  616. --- 36,44 ----
  617.   
  618.   #ifndef lint
  619.   #ifdef QUEUE
  620. ! static char sccsid[] = "@(#)queue.c    8.41.1.1 (Berkeley) 2/10/95 (with queueing)";
  621.   #else
  622. ! static char sccsid[] = "@(#)queue.c    8.41.1.1 (Berkeley) 2/10/95 (without queueing)";
  623.   #endif
  624.   #endif /* not lint */
  625.   
  626. ***************
  627. *** 210,216 ****
  628.   
  629.       /* message from envelope, if it exists */
  630.       if (e->e_message != NULL)
  631. !         fprintf(tfp, "M%s\n", e->e_message);
  632.   
  633.       /* send various flag bits through */
  634.       p = buf;
  635. --- 210,216 ----
  636.   
  637.       /* message from envelope, if it exists */
  638.       if (e->e_message != NULL)
  639. !         fprintf(tfp, "M%s\n", denlstring(e->e_message));
  640.   
  641.       /* send various flag bits through */
  642.       p = buf;
  643. ***************
  644. *** 224,237 ****
  645.   
  646.       /* $r and $s and $_ macro values */
  647.       if ((p = macvalue('r', e)) != NULL)
  648. !         fprintf(tfp, "$r%s\n", p);
  649.       if ((p = macvalue('s', e)) != NULL)
  650. !         fprintf(tfp, "$s%s\n", p);
  651.       if ((p = macvalue('_', e)) != NULL)
  652. !         fprintf(tfp, "$_%s\n", p);
  653.   
  654.       /* output name of sender */
  655. !     fprintf(tfp, "S%s\n", e->e_from.q_paddr);
  656.   
  657.       /* output list of error recipients */
  658.       printctladdr(NULL, NULL);
  659. --- 224,237 ----
  660.   
  661.       /* $r and $s and $_ macro values */
  662.       if ((p = macvalue('r', e)) != NULL)
  663. !         fprintf(tfp, "$r%s\n", denlstring(p));
  664.       if ((p = macvalue('s', e)) != NULL)
  665. !         fprintf(tfp, "$s%s\n", denlstring(p));
  666.       if ((p = macvalue('_', e)) != NULL)
  667. !         fprintf(tfp, "$_%s\n", denlstring(p));
  668.   
  669.       /* output name of sender */
  670. !     fprintf(tfp, "S%s\n", denlstring(e->e_from.q_paddr));
  671.   
  672.       /* output list of error recipients */
  673.       printctladdr(NULL, NULL);
  674. ***************
  675. *** 240,246 ****
  676.           if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
  677.           {
  678.               printctladdr(q, tfp);
  679. !             fprintf(tfp, "E%s\n", q->q_paddr);
  680.           }
  681.       }
  682.   
  683. --- 240,246 ----
  684.           if (!bitset(QDONTSEND|QBADADDR, q->q_flags))
  685.           {
  686.               printctladdr(q, tfp);
  687. !             fprintf(tfp, "E%s\n", denlstring(q->q_paddr));
  688.           }
  689.       }
  690.   
  691. ***************
  692. *** 251,257 ****
  693.               (queueall && !bitset(QDONTSEND|QBADADDR|QSENT, q->q_flags)))
  694.           {
  695.               printctladdr(q, tfp);
  696. !             fprintf(tfp, "R%s\n", q->q_paddr);
  697.               if (announce)
  698.               {
  699.                   e->e_to = q->q_paddr;
  700. --- 251,257 ----
  701.               (queueall && !bitset(QDONTSEND|QBADADDR|QSENT, q->q_flags)))
  702.           {
  703.               printctladdr(q, tfp);
  704. !             fprintf(tfp, "R%s\n", denlstring(q->q_paddr));
  705.               if (announce)
  706.               {
  707.                   e->e_to = q->q_paddr;
  708. ***************
  709. *** 427,433 ****
  710.       else
  711.           uname = pw->pw_name;
  712.   
  713. !     fprintf(tfp, "C%s:%s\n", uname, a->q_paddr);
  714.   }
  715.   
  716.    /*
  717. --- 427,433 ----
  718.       else
  719.           uname = pw->pw_name;
  720.   
  721. !     fprintf(tfp, "C%s:%s\n", uname, denlstring(a->q_paddr));
  722.   }
  723.   
  724.    /*
  725. *** src/readcf.c.OLD    Thu Feb  9 12:37:27 1995
  726. --- src/readcf.c    Fri Feb 10 07:45:09 1995
  727. ***************
  728. *** 33,39 ****
  729.    */
  730.   
  731.   #ifndef lint
  732. ! static char sccsid[] = "@(#)readcf.c    8.23 (Berkeley) 3/18/94";
  733.   #endif /* not lint */
  734.   
  735.   # include "sendmail.h"
  736. --- 33,39 ----
  737.    */
  738.   
  739.   #ifndef lint
  740. ! static char sccsid[] = "@(#)readcf.c    8.23.1.2 (Berkeley) 2/10/95";
  741.   #endif /* not lint */
  742.   
  743.   # include "sendmail.h"
  744. ***************
  745. *** 1300,1306 ****
  746.           break;
  747.   
  748.         case 'M':        /* define macro */
  749. !         define(val[0], newstr(&val[1]), CurEnv);
  750.           sticky = FALSE;
  751.           break;
  752.   
  753. --- 1300,1309 ----
  754.           break;
  755.   
  756.         case 'M':        /* define macro */
  757. !         p = newstr(&val[1]);
  758. !         if (!safe)
  759. !             cleanstrcpy(p, p, MAXNAME);
  760. !         define(val[0], p, CurEnv);
  761.           sticky = FALSE;
  762.           break;
  763.   
  764. *** src/recipient.c.OLD    Thu Feb  9 12:21:42 1995
  765. --- src/recipient.c    Mon Feb 20 17:31:39 1995
  766. ***************
  767. *** 33,39 ****
  768.    */
  769.   
  770.   #ifndef lint
  771. ! static char sccsid[] = "@(#)recipient.c    8.44 (Berkeley) 2/28/94";
  772.   #endif /* not lint */
  773.   
  774.   # include "sendmail.h"
  775. --- 33,39 ----
  776.    */
  777.   
  778.   #ifndef lint
  779. ! static char sccsid[] = "@(#)recipient.c    8.44.1.4 (Berkeley) 2/20/95";
  780.   #endif /* not lint */
  781.   
  782.   # include "sendmail.h"
  783. ***************
  784. *** 75,81 ****
  785. --- 75,84 ----
  786.       bool firstone;        /* set on first address sent */
  787.       char delimiter;        /* the address delimiter */
  788.       int naddrs;
  789. +     int i;
  790.       char *oldto = e->e_to;
  791. +     char *bufp;
  792. +     char buf[MAXNAME + 1];
  793.   
  794.       if (list == NULL)
  795.       {
  796. ***************
  797. *** 102,108 ****
  798.       al = NULL;
  799.       naddrs = 0;
  800.   
  801. !     for (p = list; *p != '\0'; )
  802.       {
  803.           auto char *delimptr;
  804.           register ADDRESS *a;
  805. --- 105,119 ----
  806.       al = NULL;
  807.       naddrs = 0;
  808.   
  809. !     /* make sure we have enough space to copy the string */
  810. !     i = strlen(list) + 1;
  811. !     if (i <= sizeof buf)
  812. !         bufp = buf;
  813. !     else
  814. !         bufp = xalloc(i);
  815. !     strcpy(bufp, denlstring(list));
  816. !     for (p = bufp; *p != '\0'; )
  817.       {
  818.           auto char *delimptr;
  819.           register ADDRESS *a;
  820. ***************
  821. *** 143,148 ****
  822. --- 154,161 ----
  823.       }
  824.   
  825.       e->e_to = oldto;
  826. +     if (bufp != buf)
  827. +         free(bufp);
  828.       return (naddrs);
  829.   }
  830.    /*
  831. *** src/savemail.c.OLD    Thu Feb  9 12:37:27 1995
  832. --- src/savemail.c    Thu Feb  9 12:24:32 1995
  833. ***************
  834. *** 33,39 ****
  835.    */
  836.   
  837.   #ifndef lint
  838. ! static char sccsid[] = "@(#)savemail.c    8.28 (Berkeley) 3/11/94";
  839.   #endif /* not lint */
  840.   
  841.   # include "sendmail.h"
  842. --- 33,39 ----
  843.    */
  844.   
  845.   #ifndef lint
  846. ! static char sccsid[] = "@(#)savemail.c    8.29 (Berkeley) 5/10/94";
  847.   #endif /* not lint */
  848.   
  849.   # include "sendmail.h"
  850. ***************
  851. *** 521,527 ****
  852.               e->e_id, ee->e_id, msg);
  853.   # endif
  854.   
  855. !     (void) sprintf(buf, "Returned mail: %s", msg);
  856.       addheader("Subject", buf, ee);
  857.       if (SendMIMEErrors)
  858.       {
  859. --- 521,527 ----
  860.               e->e_id, ee->e_id, msg);
  861.   # endif
  862.   
  863. !     (void) sprintf(buf, "Returned mail: %.*s", sizeof buf - 20, msg);
  864.       addheader("Subject", buf, ee);
  865.       if (SendMIMEErrors)
  866.       {
  867. *** src/sendmail.h.OLD    Thu Feb  9 12:21:51 1995
  868. --- src/sendmail.h    Fri Feb 10 07:38:06 1995
  869. ***************
  870. *** 31,37 ****
  871.    * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  872.    * SUCH DAMAGE.
  873.    *
  874. !  *    @(#)sendmail.h    8.43 (Berkeley) 4/14/94
  875.    */
  876.   
  877.   /*
  878. --- 31,37 ----
  879.    * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  880.    * SUCH DAMAGE.
  881.    *
  882. !  *    @(#)sendmail.h    8.43.1.1 (Berkeley) 2/10/95
  883.    */
  884.   
  885.   /*
  886. ***************
  887. *** 41,47 ****
  888.   # ifdef _DEFINE
  889.   # define EXTERN
  890.   # ifndef lint
  891. ! static char SmailSccsId[] =    "@(#)sendmail.h    8.43        4/14/94";
  892.   # endif
  893.   # else /*  _DEFINE */
  894.   # define EXTERN extern
  895. --- 41,47 ----
  896.   # ifdef _DEFINE
  897.   # define EXTERN
  898.   # ifndef lint
  899. ! static char SmailSccsId[] =    "@(#)sendmail.h    8.43.1.1        2/10/95";
  900.   # endif
  901.   # else /*  _DEFINE */
  902.   # define EXTERN extern
  903. ***************
  904. *** 956,961 ****
  905. --- 956,962 ----
  906.   extern char        *shortenstring __P((char *, int));
  907.   extern bool        usershellok __P((char *));
  908.   extern void        commaize __P((HDR *, char *, int, MCI *, ENVELOPE *));
  909. + extern char        *denlstring __P((char *));
  910.   
  911.   /* ellipsis is a different case though */
  912.   #ifdef __STDC__
  913. *** src/util.c.OLD    Thu Feb  9 12:37:26 1995
  914. --- src/util.c    Fri Feb 10 10:48:31 1995
  915. ***************
  916. *** 33,39 ****
  917.    */
  918.   
  919.   #ifndef lint
  920. ! static char sccsid[] = "@(#)util.c    8.39 (Berkeley) 4/14/94";
  921.   #endif /* not lint */
  922.   
  923.   # include "sendmail.h"
  924. --- 33,39 ----
  925.    */
  926.   
  927.   #ifndef lint
  928. ! static char sccsid[] = "@(#)util.c    8.39.1.2 (Berkeley) 2/10/95";
  929.   #endif /* not lint */
  930.   
  931.   # include "sendmail.h"
  932. ***************
  933. *** 1464,1467 ****
  934. --- 1464,1547 ----
  935.       strcpy(buf + m, "...");
  936.       strcpy(buf + m + 3, s + l - m);
  937.       return buf;
  938. + }
  939. +  /*
  940. + **  CLEANSTRCPY -- copy string keeping out bogus characters
  941. + **
  942. + **    Parameters:
  943. + **        t -- "to" string.
  944. + **        f -- "from" string.
  945. + **        l -- length of space available in "to" string.
  946. + **
  947. + **    Returns:
  948. + **        none.
  949. + */
  950. + void
  951. + cleanstrcpy(t, f, l)
  952. +     register char *t;
  953. +     register char *f;
  954. +     int l;
  955. + {
  956. + #ifdef LOG
  957. +     /* check for newlines and log if necessary */
  958. +     (void) denlstring(f);
  959. + #endif
  960. +     l--;
  961. +     while (l > 0 && *f != '\0')
  962. +     {
  963. +         if (isascii(*f) &&
  964. +             (isalnum(*f) || strchr("!#$%&'*+-./^_`{|}~", *f) != NULL))
  965. +         {
  966. +             l--;
  967. +             *t++ = *f;
  968. +         }
  969. +         f++;
  970. +     }
  971. +     *t = '\0';
  972. + }
  973. +  /*
  974. + **  DENLSTRING -- convert newlines in a string to spaces
  975. + **
  976. + **    Parameters:
  977. + **        s -- the input string
  978. + **
  979. + **    Returns:
  980. + **        A pointer to a version of the string with newlines
  981. + **        mapped to spaces.  This should be copied.
  982. + */
  983. + char *
  984. + denlstring(s)
  985. +     char *s;
  986. + {
  987. +     register char *p;
  988. +     int l;
  989. +     static char *bp = NULL;
  990. +     static int bl = 0;
  991. +     if (strchr(s, '\n') == NULL)
  992. +         return s;
  993. +     l = strlen(s) + 1;
  994. +     if (bl < l)
  995. +     {
  996. +         /* allocate more space */
  997. +         if (bp != NULL)
  998. +             free(bp);
  999. +         bp = xalloc(l);
  1000. +         bl = l;
  1001. +     }
  1002. +     strcpy(bp, s);
  1003. +     for (p = bp; (p = strchr(p, '\n')) != NULL; )
  1004. +         *p++ = ' ';
  1005. + #ifdef LOG
  1006. +     p = macvalue('_', CurEnv);
  1007. +     syslog(LOG_ALERT, "POSSIBLE ATTACK from %s: newline in string \"%s\"",
  1008. +         p == NULL ? "[UNKNOWN]" : p, bp);
  1009. + #endif
  1010. +     return bp;
  1011.   }
  1012. *** src/version.c.OLD    Fri Feb 10 08:17:14 1995
  1013. --- src/version.c    Thu Feb  9 12:38:27 1995
  1014. ***************
  1015. *** 33,39 ****
  1016.    */
  1017.   
  1018.   #ifndef lint
  1019. ! static char sccsid[] = "@(#)version.c    8.6.9.1 (Berkeley) 4/18/94";
  1020.   #endif /* not lint */
  1021.   
  1022. ! char    Version[] = "8.6.9";
  1023. --- 33,39 ----
  1024.    */
  1025.   
  1026.   #ifndef lint
  1027. ! static char sccsid[] = "@(#)version.c    8.6.10.1 (Berkeley) 2/7/95";
  1028.   #endif /* not lint */
  1029.   
  1030. ! char    Version[] = "8.6.10";
  1031.